<template>
  <div>
    <div class="title">
      <el-row>
        <el-col :span="1" style="width: 50px;">
          <span style="color:#757575;">位置 :</span>
        </el-col>
        <el-col :span="20">
          <span @click="tableshow" class="hand" :class="{'text' : !secondshow}">简历反馈</span>
          <span v-if="secondshow" :class="{'text' : secondshow}">> {{secondtitle}}</span>
        </el-col>
      </el-row>
    </div>
    <div class="posttable" v-show="!addShow">
      <el-row type="flex" justify="center">
        <el-col :span="23">
          <div class="tabletitle" style="float: left;">
            <el-radio v-model="radio" @change="radioChange" label="未反馈">未反馈</el-radio>
            <el-radio v-model="radio" @change="radioChange" label="已反馈">已反馈</el-radio>
          </div>
          <div style="margin-bottom:20px;float: right;">
            <el-row type="flex" justify="space-between" style="margin-top: 11px;" class="btn">
              <el-input
                style="width: 136px;"
                size="small"
                placeholder="查找"
                v-model.trim="inputValue"
                @keydown.enter.native="searchMsg"
              >
                <i
                  slot="suffix"
                  class="el-input__icon el-icon-search"
                  style="cursor: pointer;"
                  @click="searchMsg"
                ></i>
              </el-input>
              <div style="margin-left: 5px;">
                <el-button
                  style="background: linear-gradient(to bottom, #feaa12 0%, #f28316 100%);"
                  v-if="zhuliUnfeedback"
                  class="back"
                  size="small"
                  round
                  @click="backClick"
                >通过</el-button>
                <el-button
                  v-if="zhuliUnfeedback"
                  class="back"
                  size="small"
                  round
                  @click="unpassbackClick"
                >未通过</el-button>
                <el-button class="colsure"  v-if="zhuliUnfeedback" size="small" round @click="demandclosureClick">需求关闭</el-button>
                <el-button v-if="unfeedback" class="send" size="small" round @click="pushClick">发送</el-button>
              </div>
            </el-row>
          </div>
        </el-col>
      </el-row>
      <el-row type="flex" justify="center" class="feedback">
        <el-col :span="23">
          <el-table
            class="resutable"
            :data="tableData"
            highlight-current-row
            row-key="id"
            @current-change="handleCurrentChange"
            @row-click="getRowKey"
            @expand-change="postCheck"
            @selection-change="handleSelectionChange"
            :row-class-name="tableRowClassName"
            ref="multipleTable"
          >
            <el-table-column
              v-if="radio == '已反馈'"
              type="selection"
              :reserve-selection="true"
              width="55"
            ></el-table-column>
            <el-table-column label="推送客户" width="120">
              <template slot-scope="scope">
                <!-- prop="name" -->
                <span style="cursor: pointer; color:#1198ff;" @click="viewdetail(scope.row)">
                  {{scope.row.customerName}}
                  <span
                    v-if="scope.row.type == '待定' || scope.row.type == '未联系'"
                  >({{scope.row.type}})</span>
                </span>
              </template>
            </el-table-column>
            <el-table-column label="需求编号" width="140">
              <template slot-scope="scope">
                <!-- prop="name" -->
                <span
                  style="cursor: pointer; color:#1198ff;"
                  @click="viewjobdemand(scope.row)"
                >{{scope.row.requireNum}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="postName" label="推送职位"></el-table-column>
            <el-table-column prop="postLevel" label="职位级别"></el-table-column>
            <el-table-column prop="area" label="所属区域"></el-table-column>
            <el-table-column label="姓名">
              <template slot-scope="scope">
                <!-- prop="name" -->
                <span>
                  <a
                    :href="scope.row.group+'/'+scope.row.fileAddress"
                    class="resumeLink"
                    target="_blank"
                  >{{scope.row.name}}</a>
                </span>
              </template>
            </el-table-column>
            <el-table-column label="毕业时间">
              <template slot-scope="scope">
                <span>{{scope.row.graduationTime}}</span>
              </template>
            </el-table-column>
            <el-table-column label="出生年月">
              <template slot-scope="scope">
                <span>{{scope.row.birthday}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="phone" label="联系方式"></el-table-column>
            <el-table-column prop="status" label="离职状态"></el-table-column>
            <el-table-column label="期望薪资">
              <template slot-scope="scope">
                <span>{{scope.row.expectSalary}}k*{{scope.row.expectSalaryNum}}</span>
              </template>
            </el-table-column>
            <el-table-column label="到岗时间">
              <template slot-scope="scope">
                <span>{{scope.row.entryTime}}</span>
              </template>
            </el-table-column>
            <el-table-column label="推送时间">
              <template slot-scope="scope">
                <span>{{scope.row.pushTime | converTime("YYYY-MM-DD")}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="pusherName" label="简历推送人" v-if="iszhuli"></el-table-column>
            <el-table-column
              prop="initialEvaluation"
              label="初步评价"
              v-if="iszhuli"
              width="300"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column
              prop="initialEvaluation"
              label="备注信息"
              v-if="!iszhuli"
              width="300"
              show-overflow-tooltip
            ></el-table-column>
            <el-table-column label="是否已读" v-if="checked && !iszhuli">
              <template slot-scope="scope">
                <div v-if="scope.row.prRead == 'Y'">
                  <i class="el-icon-check"></i>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="是否已读" v-if="checked && iszhuli">
              <template slot-scope="scope">
                <div v-if="scope.row.asRead == 'Y'">
                  <i class="el-icon-check"></i>
                </div>
              </template>
            </el-table-column>
            <el-table-column type="expand" label="功能区" width="80" v-if="iszhuli && unfeedback">
              <template slot-scope="props">
                <div style="text-align:left;margin-left:10px;font-size:14px;line-height:20px;">
                  <p style="color: #fe423e;" v-if="props.row.interviewTimeok">备注</p>
                  <p>{{props.row.interviewTimeok}}</p>
                </div>
                <div style="text-align:left;margin-left:10px;font-size:14px;line-height:20px;">
                  <p style="color: #fe423e;" v-if="props.row.comTime ">面试时间反馈</p>
                  <p>{{props.row.comTime | converTime("YYYY-MM-DD HH:mm")}}</p>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <div class="pager">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="pagehandleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[5,10,15]"
              :page-size="pagesize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="totalcount"
            ></el-pagination>

            <!--            回复通过简历弹出框-->
            <el-dialog
              class="addP"
              title="回复通过简历"
              :visible.sync="feedBackVisible"
              width="415px"
              :before-close="close"
            >
              <el-form :model="formL" :rules="rules" ref="formL" label-position="top">
                <el-form-item label="客户约面试时间" prop="time" v-if="timeBool">
                  <el-date-picker
                    v-model="formL.time"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm"
                    format="yyyy-MM-dd HH:mm"
                    placeholder="选择面试时间"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item label="简历反馈" :label-width="formLabelWidth" prop="reason">
                  <el-input
                    type="textarea"
                    :autosize="{minRows:2}"
                    v-model.trim="formL.reason"
                    placeholder="请输入简历反馈"
                  ></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button
                  class="sure"
                  :disabled="backdis"
                  type="primary"
                  round
                  @click="backConfirm('formL')"
                >提交</el-button>
                <el-button class="cancel" round @click="close">取消</el-button>
              </div>
            </el-dialog>
            <!--            回复需求关闭弹出框-->
            <el-dialog
              class="addP"
              title="回复需求关闭"
              :visible.sync="closeBackVisible"
              width="415px"
              :before-close="close2"
            >
              <el-form :model="editreply" :rules="rulesclose" ref="editreply" label-position="top">
                <el-form-item label="简历反馈" :label-width="formLabelWidth" prop="reply">
                  <el-input type="text" v-model.trim="editreply.reply" placeholder="该岗位需求关闭"></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button
                  class="sure"
                  :disabled="rebackdis"
                  type="primary"
                  round
                  @click="backreply('editreply')"
                >提交</el-button>
                <el-button class="cancel" round @click="close2">取消</el-button>
              </div>
            </el-dialog>

            <!--             回复未通过简历弹出框   -->
            <el-dialog
              class="addP"
              title="回复未通过简历"
              :visible.sync="feedBackVisible1"
              width="415px"
              :before-close="nopassclose"
            >
              <el-form
                :model="unpassformL"
                :rules="unpassrule"
                ref="unpassformL"
                label-position="top"
              >
                <el-form-item label="简历反馈" :label-width="formLabelWidth" prop="reason">
                  <el-input
                    type="textarea"
                    :autosize="{minRows:2}"
                    v-model.trim="unpassformL.unpassreason"
                    placeholder="请输入简历反馈"
                  ></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button
                  :disabled="unpassdis"
                  class="sure"
                  type="primary"
                  round
                  @click="unpassBack('unpassformL')"
                >提交</el-button>
                <el-button class="cancel" round @click="nopassclose()">取消</el-button>
              </div>
            </el-dialog>
            <!--            未选择表格当前行的弹出框-->
            <el-dialog
              title="错误"
              :visible.sync="editdialogVisible"
              width="30%"
              :before-close="handleClose"
              class="deletedialog"
            >
              <div style="text-align: center">
                <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;">
                  <span style="font-size: 16px;color: #333;margin-left: 12px;">尚未选择任何简历</span>
                </i>
              </div>
              <span slot="footer" class="dialog-footer">
                <el-button class="sure" round @click="handleOpen">确 定</el-button>
                <el-button round @click="handleClose" class="cancel">取 消</el-button>
              </span>
            </el-dialog>
            <!--            该需求状态正常，不可操作！-->
            <el-dialog
              title="错误"
              :visible.sync="closedialogVisible"
              width="30%"
              :before-close="handleClose1"
              class="deletedialog"
            >
              <div style="text-align: center">
                <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;">
                  <span style="font-size: 16px;color: #333;margin-left: 12px;">该需求状态正常，不可操作！</span>
                </i>
              </div>
              <span slot="footer" class="dialog-footer">
                <el-button class="sure" round @click="handleClose1">确 定</el-button>
                <el-button round @click="handleClose1" class="cancel">取 消</el-button>
              </span>
            </el-dialog>
            <!--  接收人邮箱不同的弹出框-->
            <el-dialog
              title="错误"
              :visible.sync="samemailDialogVisible"
              width="30%"
              :before-close="reclose"
              class="deletedialog"
            >
              <div style="text-align: center">
                <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;">
                  <span style="font-size: 16px;color: #333;margin-left: 12px;">统一接口人邮箱不同</span>
                </i>
              </div>
              <span slot="footer" class="dialog-footer">
                <el-button class="sure" round @click="reclose">确 定</el-button>
                <el-button round @click="reclose" class="cancel">取 消</el-button>
              </span>
            </el-dialog>
            <el-dialog
              title="错误"
              :visible.sync="differcopierDialogVisible"
              width="30%"
              :before-close="reclose1"
              class="deletedialog"
            >
              <div style="text-align: center">
                <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;">
                  <span style="font-size: 16px;color: #333;margin-left: 12px;">需求对应的抄送人不同</span>
                </i>
              </div>
              <span slot="footer" class="dialog-footer">
                <el-button class="sure" round @click="reclose1">确 定</el-button>
                <el-button round @click="reclose1" class="cancel">取 消</el-button>
              </span>
            </el-dialog>

            <el-dialog :visible.sync="dialogFormVisible" :before-close="cancelSend" class="back1">
              <div class="dialogBox">
                <el-row>
                  <el-col :span="2" style="line-height:28px;color:#0e6195">收件人：</el-col>
                  <el-col :span="10" class="receive">
                    <span>{{mail}}</span>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="23">
                    <div class="line"></div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="2" style="line-height:28px;color:#0e6195">抄送人：</el-col>
                  <el-col :span="18" style="line-height:28px;font-size:12px;">
                    <span v-for="(item,index) in copymail" :key="index">
                      {{item}}
                      <span>,</span>
                    </span>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="23">
                    <div class="darkline"></div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col
                    :span="2"
                    style="line-height:28px;color:#999798"
                  >主&nbsp;&nbsp;&nbsp;&nbsp;题：</el-col>
                  <el-col :span="10" style="line-height:28px;font-size:12px;font-weight:700;">
                    <el-select
                      v-if="remark"
                      size="mini"
                      filterable
                      v-model="theme"
                      placeholder="请选择主题"
                      @change="getMailData"
                      v-loading="loading"
                    >
                      <el-option v-for="item in themelist" :key="item" :label="item" :value="item"></el-option>
                    </el-select>
                    <el-select
                      v-if="!remark"
                      size="mini"
                      filterable
                      v-model="sendTheme"
                      placeholder="请选择主题"
                      @change="sendThemeChange"
                      v-loading="sendLoading"
                    >
                      <el-option
                        v-for="(item,index) in sendThemeList"
                        :key="index"
                        :label="item"
                        :value="item"
                      ></el-option>
                    </el-select>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="23">
                    <div class="lightLine"></div>
                  </el-col>
                </el-row>
                <el-row style="border: 1px solid #ccc;">
                  <el-col :span="20">
                    <p>您好:</p>
                    <p>&nbsp;&nbsp;面试安排如下</p>
                  </el-col>
                  <el-col :span="12" style="padding-left: 10px;" class="mailtable mailtable1">
                    <el-table
                      class="tablelist"
                      ref="mailtable"
                      style="width: 522px;"
                      :data="maildata"
                      border
                    >
                      <el-table-column width="92" prop="name" label="姓名"></el-table-column>
                      <el-table-column width="200" prop="postName" label="岗位"></el-table-column>
                      <el-table-column width="230" label="面试时间">
                        <template slot-scope="scope">
                          <el-input v-model.trim="scope.row.comTime" placeholder="请输入面试时间"></el-input>
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-col>
                  <el-col
                    style="text-indent: 1.5em;margin-top: 30px;margin-left: 10px;margin-bottom: 30px;"
                  >
                    <p>周颖</p>
                    <p>软件研发中心 人力资源部</p>
                    <p>
                      <span>公司 :</span>
                      <span>北京神州新桥科技有限公司</span>
                    </p>
                    <p>
                      <span>地址 :</span>
                      <span>北京市海淀区长春桥路11号万柳亿城大厦2号楼16层</span>
                    </p>
                    <p>
                      <span>邮箱 :</span>
                      <span>sinorjyfzx@sino-bridge.com</span>
                    </p>
                    <p>
                      <span>电话 :</span>
                      <span>(+86)15962999175</span>
                    </p>
                  </el-col>

                  <el-col style="margin-bottom: 18px;">
                    <el-row type="flex" justify="center">
                      <el-col :span="23">
                        <div class="lightLine"></div>
                      </el-col>
                    </el-row>
                  </el-col>

                  <el-col></el-col>
                  <el-col>
                    <div v-html="texthtml"></div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col v-if="this.file" :span="24">
                    <span
                      v-for="(item,index) in file"
                      :key="index"
                      style="margin-right:10px;line-height:40px"
                    >
                      <a
                        :href="item.fileUrl"
                        class="resumeLink"
                        target="_blank"
                      >{{item.originalFilename}}</a>
                    </span>
                  </el-col>
                </el-row>
              </div>
              <div slot="title" class="dialog-title">
                <el-button
                  type="primary"
                  @click="sendClick"
                  style="font-size:16px;"
                  :disabled="disabled"
                >
                  <i class="iconfont icon-plane"></i>
                  <span style="margin-left:6px;">发送</span>
                </el-button>
                <el-button @click="cancelSend">取 消</el-button>
                <el-input v-model="days" style="width:270px" placeholder="请输入需要寻找的天数内的发件箱主题"></el-input>
                <el-button type="primary" @click="getSendSub1">寻找收件箱</el-button>
                <el-button type="warning" @click="getSendSub">寻找发件箱</el-button>
                <el-button type="warning" @click="getallSendSub">寻找所有发件箱</el-button>
              </div>
            </el-dialog>
          </div>
        </el-col>
      </el-row>
    </div>
    <div v-if="type == 2">
      <job-Detail v-show="addShow" :detail-no="detailno"></job-Detail>
    </div>
    <div v-if="type == 3">
      <upload-Detail v-show="addShow" :detail-code="detailcode"></upload-Detail>
    </div>
  </div>
</template>
<script>
import axios from "axios";
import JobDetail from "../resumeupload/jobdetail.vue";
import UploadDetail from "../resumeupload/uploaddetail.vue";
import moment from "moment";
import tagsView from '../../store/modules/tagsView'

export default {
  data() {
    return {
      inputValue: "",
      days: "",
      secondshow: false,
      editdialogVisible: false,
      closedialogVisible: false,
      differcopierDialogVisible: false,
      radio: "未反馈",
      sendLoading: true,
      formL: {
        time: null,
        reason: ""
      },
      editreply: {
        reply: "该岗位需求关闭"
      },
      unpassformL: {
        unpassreason: "该简历未通过"
      },
      zhuliUnfeedback: true, //控制回复按钮显示隐藏的
      unfeedback: false,
      tableData: [],
      currentPage: 1,
      rowChecked: false,
      pagesize: 15,
      totalcount: 0,
      checked: false,
      type: null,
      secondtitle: "",
      addShow: false,
      rowId: "",
      timeBool: true,
      pusher: "",
      currentRow: null,
      iszhuli: true,
      feedBackVisible: false,
      closeBackVisible: false,
      feedBackVisible1: false,
      dialogFormVisible: false,
      samemailDialogVisible: false,
      receiveMails: [],
      themelist: [],
      theme: "",
      sendTheme: "",
      sendThemeList: [],
      loading: true,
      disabled: false,
      remark: true,
      file: null,
      mail: "",
      copymail: [],
      formLabelWidth: "120px",
      multipleSelection: [],
      maildata: [],
      texthtml: "",
      rules: {
        time: [{ required: true, message: "请选择面试时间", trigger: "change" }]
      },
      rulesclose: {
        reply: [{ required: true, message: "请输入回复信息", trigger: "blur" }]
      },
      unpassrule: {
        unpassreason: [
          { required: true, message: "请输入反馈详情", trigger: "blur" }
        ]
      },
      backdis: false,
      rebackdis: false,
      unpassdis: false,
      id: []
    };
  },
  created() {
    this.success();
    this.$bus.$on("notify", () => {
      this.notify();
    });
    if(tagsView.state.identity == 7){
        this.zhuliUnfeedback = false;
      }
  },
  methods: {
    notify() {
      this.radio = "已反馈";
      axios
        .post(this.url + "/feed/feedbackalready", {
          condition: this.inputValue,
          pageNum: this.currentPage,
          pageSize: this.pagesize
        })
        .then(res => {
          if (res.data.code == 200) {
            if (res.data.data !== null) {
              this.tableData = res.data.data.list;
              this.totalcount = res.data.data.total;
            }
          }
        });
    },
    success() {
      axios
        .post(this.url + "/feed/nofeedback", {
          condition: this.inputValue,
          pageNum: this.currentPage,
          pageSize: this.pagesize
        })
        .then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            if (res.data.data !== null) {
              this.tableData = res.data.data.list;
              this.totalcount = res.data.data.total;
            }
          }
        });
    },
    //搜索
    searchMsg() {
      this.currentPage = 1;
      if (this.radio == "未反馈") {
        axios
          .post(this.url + "/feed/nofeedback", {
            condition: this.inputValue,
            pageNum: this.currentPage,
            pageSize: this.pagesize
          })
          .then(res => {
            if (res.data.code == 200) {
              if (res.data.data !== null) {
                this.tableData = res.data.data.list;
                this.totalcount = res.data.data.total;
              }
            }
          });
      } else if (this.radio == "已反馈") {
        // /feedbackalready
        axios
          .post(this.url + "/feed/feedbackalready", {
            condition: this.inputValue,
            pageNum: this.currentPage,
            pageSize: this.pagesize
          })
          .then(res => {
            if (res.data.code == 200) {
              if (res.data.data !== null) {
                this.tableData = res.data.data.list;
                this.totalcount = res.data.data.total;
              }
            }
          });
      }
    },
    tableshow(row) {
      this.addShow = false;
      this.secondshow = false;
      this.$refs.multipleTable.setCurrentRow(row);
      this.type = null;
      this.typechange1();
    },
    // 根据是否是PM 改变类名 改变样式
    tableRowClassName({ row, rowIndex }) {
      if (row.resumeState == "PM") {
        return "send-row";
      }
      return "";
    },
    //需求关闭
    demandclosureClick() {
      if (this.currentRow) {
        axios
          .post(this.url + "/feed/isClose", {
            requireNum: this.currentRow.requireNum
          })
          .then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              this.editreply.reply = "该岗位需求关闭";
              this.closeBackVisible = true;
              document.documentElement.style.overflow = "hidden";
            } else if (res.data.message == "error") {
              this.closedialogVisible = true;
              document.documentElement.style.overflow = "hidden";
            }
          });
      } else {
        this.editdialogVisible = true;
        document.documentElement.style.overflow = "hidden";
      }
    },
    //通过简历
    backClick() {
      if (this.currentRow == null) {
        this.editdialogVisible = true;
        document.documentElement.style.overflow = "hidden";
      } else {
        this.formL.reason = "";
        axios
          .post(this.url + "/feed/asstime", {
            id: this.currentRow.id
          })
          .then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200 && res.data.data == "1") {
              this.timeBool = true;
              this.formL.reason = "简历通过可约面试";
            } else {
              this.timeBool = false;
              this.formL.reason = "简历通过，请尽快与候选人沟通安排面试时间";
            }
          });
        this.editdialogVisible = false;
        this.feedBackVisible = true;
        this.formL.time = null;
        document.documentElement.style.overflow = "hidden";
      }
    },
    //未通过简历
    unpassbackClick() {
      if (this.currentRow == null) {
        document.documentElement.style.overflow = "hidden";
        this.editdialogVisible = true;
      } else {
        document.documentElement.style.overflow = "hidden";
        this.editdialogVisible = false;
        this.feedBackVisible1 = true;
        this.unpassformL.unpassreason = "该简历未通过";
      }
    },
    handleOpen() {
      this.editdialogVisible = false;
      document.documentElement.style.overflow = "auto";
    },
    handleClose() {
      this.editdialogVisible = false;
      document.documentElement.style.overflow = "auto";
    },
    handleClose1() {
      this.closedialogVisible = false;
      document.documentElement.style.overflow = "auto";
    },
    //查看上传内容
    viewdetail(val) {
      this.detailcode = val;
      this.addShow = !this.addShow;
      this.secondtitle = "查看上传内容";
      this.secondshow = !this.secondshow;
      this.type = 3;
    },
    //查看职位需求
    viewjobdemand(val) {
      this.detailno = val.requireNum;
      this.addShow = !this.addShow;
      this.secondtitle = "职位需求";
      this.secondshow = true;
      this.type = 2;
    },
    getRowKey(row) {
      this.rowId = row.id;
      this.rowChecked = true;
      this.pusher = row.pusher;
      return row.id;
    },
    handleSizeChange(val) {
      this.pagesize = val;
      this.typechange1();
    },
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    pagehandleCurrentChange(val) {
      this.currentPage = val;
      this.typechange1();
    },
    //单选框变化
    radioChange(val) {
      this.currentPage = 1;
      if (val == "未反馈") {
        this.inputValue = "";
        this.zhuliUnfeedback = true;
        this.unfeedback = false;
        this.checked = false;
        this.success();
      } else {
        this.zhuliUnfeedback = false;
      }
      if (val == "已反馈") {
        this.inputValue = "";
        this.checked = true;
        this.unfeedback = true;
        this.tableData = [];
        axios
          .post(this.url + "/feed/feedbackalready", {
            condition: this.inputValue,
            pageNum: this.currentPage,
            pageSize: this.pagesize
          })
          .then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              if (res.data.data !== null) {
                this.tableData = res.data.data.list;
                this.totalcount = res.data.data.total;
              }
            }
          });
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      //处理js对象地址引用的问题，将对象转换成json对象，与原对象解除关联，在转换成js对象
      this.maildata = JSON.parse(JSON.stringify(val));
      for (var i = 0; i < this.maildata.length; i++) {
        if (
          isNaN(this.maildata[i].comTime) &&
          !isNaN(Date.parse(this.maildata[i].comTime))
        ) {
          this.maildata[i].comTime = moment(this.maildata[i].comTime).format(
            "YYYY-MM-DD HH:mm"
          );
        }
        if (this.maildata[i].interviewTimeok.indexOf("放弃面试") != -1) {
          this.maildata[i].comTime = this.maildata[i].interviewTimeok;
        }
      }
    },
    //助理对通过简历的提交
    backConfirm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.backdis = true;
          if (this.formL.time == "") {
            this.formL.time = null;
          }
          axios
            .post(this.url + "/feed/feedback", {
              id: this.rowId,
              resumeState: "PS",
              assistantRemarks: this.formL.reason,
              assTime: this.formL.time,
              pusher: this.pusher
            })
            .then(res => {
              if (res.data.code == 200) {
                this.backdis = false;
                this.feedBackVisible = false;
                this.typechange();
                this.$refs.formL.resetFields();
                document.documentElement.style.overflow = "auto";
              }
            });
        }
      });
    },
    //助理对需求关闭的提交
    backreply(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.rebackdis = true;
          axios
            .post(this.url + "/feed/upState", {
              id: this.rowId,
              resumeState: "GB",
              assistantRemarks: this.editreply.reply,
              pusher: this.pusher
            })
            .then(res => {
              this.unlogin(res.data.code);
              if (res.data.code == 200) {
                this.rebackdis = false;
                this.closeBackVisible = false;
                this.typechange();
                this.$refs.editreply.resetFields();
                document.documentElement.style.overflow = "auto";
              }
            });
        }
      });
    },
    //助理对未通过简历的提交
    unpassBack(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.unpassdis = true;
          axios
            .post(this.url + "/feed/feedback", {
              id: this.rowId,
              resumeState: "PF",
              assistantRemarks: this.unpassformL.unpassreason,
              pusher: this.pusher
            })
            .then(res => {
              if (res.data.code == 200) {
                this.unpassdis = false;
                this.feedBackVisible1 = false;
                this.typechange();
                this.$refs.unpassformL.resetFields();
                document.documentElement.style.overflow = "auto";
              }
            });
        }
      });
    },
    //助理提交简历通过或者未通过后，根据单选框的值以及搜索框内的数据来获取表格的数据
    typechange() {
      this.currentPage = 1;
      if (this.radio == "未反馈") {
        this.zhuliUnfeedback = true;
        this.unfeedback = false;
        this.checked = false;
        this.success();
      } else if (this.radio == "已反馈") {
        this.zhuliUnfeedback = false;
        this.checked = true;
        this.unfeedback = true;
        axios
          .post(this.url + "/feed/feedbackalready", {
            condition: this.inputValue,
            pageNum: this.currentPage,
            pageSize: this.pagesize
          })
          .then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              if (res.data.data !== null) {
                this.tableData = res.data.data.list;
                this.totalcount = res.data.data.total;
              }
            }
          });
      }
    },
    typechange1() {
      if (this.radio == "未反馈") {
        this.zhuliUnfeedback = true;
        this.unfeedback = false;
        this.checked = false;
        this.success();
      } else if (this.radio == "已反馈") {
        this.zhuliUnfeedback = false;
        this.checked = true;
        this.unfeedback = true;
        axios
          .post(this.url + "/feed/feedbackalready", {
            condition: this.inputValue,
            pageNum: this.currentPage,
            pageSize: this.pagesize
          })
          .then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              if (res.data.data !== null) {
                this.tableData = res.data.data.list;
                this.totalcount = res.data.data.total;
              }
            }
          });
      }
    },
    //关闭通过简历的弹出框
    close() {
      this.backdis = false;
      this.$refs.formL.resetFields();
      this.feedBackVisible = false;
      document.documentElement.style.overflow = "auto";
    },
    //关闭需求关闭的弹出框
    close2() {
      this.rebackdis = false;
      this.$refs.editreply.resetFields();
      this.closeBackVisible = false;
      document.documentElement.style.overflow = "auto";
    },
    //关闭未通过简历弹出框
    nopassclose() {
      this.unpassdis = false;
      this.feedBackVisible1 = false;
      this.$refs.unpassformL.resetFields();
      document.documentElement.style.overflow = "auto";
    },
    // 已读状态请求
    postCheck(val, rows) {
      axios
        .post(this.url + "/feed/reed", {
          id: val.id
        })
        .then(res => {
          if (res.data.code == 200) {
          }
        });
      if (rows.length == 0) {
        axios
          .post(this.url + "/feed/feedbackalready", {
            condition: "",
            pageNum: this.currentPage,
            pageSize: this.pagesize
          })
          .then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              if (res.data.data !== null) {
                this.tableData = res.data.data.list;
                this.totalcount = res.data.data.total;
              }
            }
          });
      }
    },
    cancelSend() {
      this.disabled = false;
      this.dialogFormVisible = false;
      this.loading = true;
      this.sendLoading = true;
      this.remark = true;
      this.id = [];
      document.documentElement.style.overflow = "auto";
    },
    filter(value) {
      return moment(value).format("YYYY-MM");
    },
    getMailData(val) {
      axios
        .post(this.url + "/mailreplay/getcontent", {
          sub: val
        })
        .then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.texthtml = res.data.data;
          }
        });
    },
    sendThemeChange(val) {
      this.theme = val;
      axios
        .post(this.url + "/mailreplay/getSentcontent", {
          sub: val
        })
        .then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.texthtml = res.data.data;
          }
        });
    },
    getSendSub() {
      this.remark = false;
      this.sendLoading = true;
      axios
        .post(this.url + "/mailreplay/getSentsub", {
          mail: this.mail,
          day: this.days
        })
        .then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.sendThemeList = res.data.data;
            this.sendLoading = false;
          }
        });
    },
    getSendSub1() {
      this.remark = true;
      this.loading = true;
      this.disabled = true;
      axios
        .post(this.url + "/mailreplay/getsub", {
          mail: this.mail,
          day: this.days
        })
        .then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.themelist = res.data.data;
            this.loading = false;
            this.disabled = false;
          }
        });
    },
    getallSendSub() {
      this.remark = false;
      this.sendLoading = true;
      axios
        .post(this.url + "/mailreplay/getAllSentsub", {
          mail: this.mail,
          day: this.days
        })
        .then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.sendThemeList = res.data.data;
            this.sendLoading = false;
          }
        });
    },
    sendClick() {
      var data = [];
      this.disabled = true;
      this.id = [];
      for (var i = 0; i < this.maildata.length; i++) {
        data.push({
          name: this.maildata[i].name,
          postname: this.maildata[i].postName,
          interviewTimeok: this.maildata[i].comTime
        });
        this.id.push(this.maildata[i].id);
      }
      axios
        .post(this.url + "/mailreplay/send", {
          to: this.mail,
          cc: this.copymail,
          sub: this.theme,
          content: this.texthtml,
          arr: data,
          id: this.id,
          customer: this.maildata[0].customerName
        })
        .then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.disabled = false;
            this.typechange();
            this.dialogFormVisible = false;
            this.loading = true;
            this.theme = "";
            this.texthtml = "";
            this.sendTheme = "";
            this.sendLoading = true;
            document.documentElement.style.overflow = "auto";
            this.$refs.multipleTable.clearSelection();
          }
        });
      axios
        .post(this.url + "/feed/addnewinterview", {
          id: this.id
        })
        .then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.id = [];
          }
        });
    },
    //发送按钮点击
    pushClick() {
      if (this.multipleSelection.length == 0) {
        this.editdialogVisible = true;
        document.documentElement.style.overflow = "hidden";
      } else {
        this.texthtml = "";
        this.themelist = [];
        this.mail = "";
        this.copymail = [];
        this.id = [];
        this.theme = "";
        let arr = [];
        this.days = "";
        this.loading = true;
        this.disabled = true;
        for (let i = 0, len = this.multipleSelection.length; i < len; i++) {
          arr.push(this.multipleSelection[i].requireNum);
        }

        axios
          .post(this.url + "/mailreplay/getmail", {
            arr: arr
          })
          .then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              this.editdialogVisible = false;
              this.dialogFormVisible = true;
              document.documentElement.style.overflow = "hidden";
              this.mail = res.data.data.mail;
              this.copymail = res.data.data.cc;

              axios
                .post(this.url + "/mailreplay/getsub", {
                  mail: this.mail,
                  day: this.days
                })
                .then(res => {
                  this.unlogin(res.data.code);
                  if (res.data.code == 200) {
                    this.themelist = res.data.data;
                    this.loading = false;
                    this.disabled = false;
                  }
                });
            }
            if (res.data.code == -200) {
              this.disabled = false;
              this.editdialogVisible = false;
              this.samemailDialogVisible = true;
              document.documentElement.style.overflow = "hidden";
            }
            if (res.data.code == -300) {
              this.disabled = false;
              this.editdialogVisible = false;
              this.differcopierDialogVisible = true;
              document.documentElement.style.overflow = "hidden";
            }
          });
      }
    },
    reclose() {
      this.samemailDialogVisible = false;
      document.documentElement.style.overflow = "auto";
    },
    reclose1() {
      this.differcopierDialogVisible = false;
      document.documentElement.style.overflow = "auto";
    }
  },
  components: {
    JobDetail,
    UploadDetail
  },
  beforeDestroy() {
    this.$bus.$off("notify");
  },
  watch: {
    inputValue: function(val) {
      if (val == "") {
        this.typechange();
      }
    }
  }
};
</script>
<style scoped>
.title {
  background-color: #fff;
  height: 40px;
  line-height: 40px;
  font-size: 14px;
  padding-left: 20px;
  margin-top: 6px;
  margin-bottom: 6px;
}

.text {
  color: #1099ff;
}

.posttable {
  min-height: 700px;
  background-color: #fff;
}

.tabletitle {
  margin-left: 20px;
  height: 50px;
  line-height: 50px;
}

.back {
  width: 65px;
  height: 28px;
  opacity: 0.86;
  color: #fff;
  background: linear-gradient(to bottom, #6a76c7 0%, #8995e8 100%);
  padding: 7px 15px !important;
}

.back:hover {
  color: #fff !important;
}
.back:focus {
  color: #fff !important;
}
.colsure {
  width: 65px;
  height: 28px;
  opacity: 0.86;
  color: #fff;
  background: linear-gradient(to bottom, #00cebf 0%, #009085 100%);
  padding: 7px 6px !important;
}

.colsure:hover {
  color: #fff !important;
}
.colsure:focus {
  color: #fff !important;
}
.send {
  width: 65px;
  height: 28px;
  opacity: 0.86;
  color: #fff;
  background: linear-gradient(to bottom, #feaa12 0%, #f28316 100%);
  padding: 7px 15px !important;
}

.send:hover {
  color: #fff !important;
}
.send:focus {
  color: #fff !important;
}

.resutable {
  background-color: #fff;
}

.pager {
  width: 100%;
  overflow: hidden;
  position: relative;
  margin-top: 10px;
  margin-bottom: 10px;
}

.el-pagination {
  margin-left: 50%;
  transform: translateX(-50%);
}

.resumeLink {
  cursor: pointer;
  color: #1198ff;
  text-decoration: none;
}

.line {
  height: 1px;
  background-color: #c8c8c8;
  margin-top: 3px;
  margin-bottom: 20px;
}

.darkline {
  height: 1px;
  background-color: #4288c3;
  margin-top: 10px;
  margin-bottom: 20px;
}

.lightLine {
  height: 1px;
  background-color: #cccccc;
  margin-top: 10px;
  margin-bottom: 10px;
}

@media screen and (min-width: 600px) and (max-width: 1700px) {
  .dialogBox {
    height: 400px;
    overflow-y: scroll;
    overflow-x: hidden;
  }
}

@media screen and (min-width: 1701px) and (max-width: 1920px) {
  .dialogBox {
    height: 600px;
    overflow-y: scroll;
    overflow-x: hidden;
  }
}
</style>
